package com.zhala.system.service.impl;

import com.zhala.system.domain.ZlAibox;
import com.zhala.system.domain.vo.ZlAiboxReqVo;
import com.zhala.system.mapper.ZlAiboxMapper;
import com.zhala.system.service.ZlAiboxService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Collections;
import java.util.List;

@Service
public class ZlAiboxImpl implements ZlAiboxService {


    @Autowired
    private ZlAiboxMapper zlAiboxMapper;

    @Override
    public int save(ZlAibox zlAibox) {
        return zlAiboxMapper.add(zlAibox);
    }

    @Override
    public ZlAibox getFind() {
        return zlAiboxMapper.record();
    }

    @Override
    public List<ZlAiboxReqVo> getList() {
        LocalDateTime now = LocalDateTime.now();

        // 计算 10 分钟前的日期和时间
        LocalDateTime tenMinutesAgo = now.minusMinutes(2);

        // 定义日期时间格式化器（可选）
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");

        // 格式化输出
        String currentTime = now.format(formatter);
        String timeTenMinutesAgo = tenMinutesAgo.format(formatter);
        return zlAiboxMapper.getlist(timeTenMinutesAgo,currentTime);
    }
}
